<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:75:"/www/wwwroot/zaozao/public/../application/admin/view/bill/invoice_list.html";i:1603938206;s:59:"/www/wwwroot/zaozao/application/admin/view/public/head.html";i:1597211856;}*/ ?>
<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>支付宝生活缴费系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/static/admin/css/font.css">
	<link rel="stylesheet" href="/static/admin/css/xadmin.css">
	<!--<link rel="stylesheet" href="/static/admin/css/bootstrap.min.css">
	<link rel="stylesheet" href="/static/admin/js/bootstrap.min.js">-->
	
    <script src="/static/admin/js/jquery.min.js"></script>
    <script src="/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">物业管理系统</a>
        <a>
          <cite>发票列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so"  method="get" action="<?php echo url("","",true,false);?>">
          <!--<input type="text" name="foundkeycommunity"  placeholder="搜索小区" autocomplete="off" class="layui-input" value="" id="foundkeycommunity" >-->
          <div class="layui-input-inline">
            <select name="community_id" lay-filter="community_id" id="community_id">
              <option value="">所属小区</option>
              <?php foreach($communitylist as $name): ?>
              <option value="<?php echo $name['community_id']; ?>" <?php if(isset($community_id)): if($community_id == $name['community_id']): ?>selected<?php endif; endif; ?>><?php echo $name['community_name']; ?></option>
              <?php endforeach; ?>
            </select>
          </div>
         
          
          <input class="layui-input" placeholder="房屋查询" name="room_address" value="<?php if(isset($room_address)): ?><?php echo $room_address; endif; ?>">
          <!--<input type="text" name="owner_name"  placeholder="业主姓名" autocomplete="off" class="layui-input" value="<?php if(isset($owner_name)): ?><?php echo $owner_name; endif; ?>">
          <input type="text" name="owner_phone"  placeholder="业主电话" autocomplete="off" class="layui-input" value="<?php if(isset($owner_phone)): ?><?php echo $whereroom['owner_phone']; endif; ?>">
           <input type="text" name="acct_period"  placeholder="账期" autocomplete="off" class="layui-input" value="<?php if(isset($acct_period)): ?><?php echo $acct_period; endif; ?>">-->
          <div class="layui-input-inline">
              <select name="cost_type">
                <option value="">费用类型</option>
                <?php foreach($costtype as $type): ?>
                <option value="<?php echo $type['type']; ?>" <?php if(isset($where['cost_type'])): if($where['cost_type'] == $type['type']): ?>selected<?php endif; endif; ?>><?php echo $type['type']; ?></option>
                <?php endforeach; ?>
              </select>
          </div>
          
        
           <div class="layui-input-inline">
            <select name="invoice_type">
              <option value="">发票状态</option>
              <option value="1" <?php if(isset($invoice_type)): if($invoice_type == '1'): ?>selected<?php endif; endif; ?>>已开票</option>
              <option value="3" <?php if(isset($invoice_type)): if($invoice_type == '3'): ?>selected<?php endif; endif; ?>>未开票</option>
              <option value="2" <?php if(isset($invoice_type)): if($invoice_type == '2'): ?>selected<?php endif; endif; ?>>已退票</option>
            </select>
          </div>
         
          <input class="layui-input" placeholder="开始时间" name="gmt_payment_start" id="start" <?php if(isset($gmtstart)): ?>value="<?php echo $gmtstart; ?>"<?php endif; ?>>
          <input class="layui-input" placeholder="结束时间" name="gmt_payment_end" id="end" <?php if(isset($gmtend)): ?>value="<?php echo $gmtend; ?>"<?php endif; ?>>
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <xblock>
       
       
        
        <button class="layui-btn" onclick="invoice()"><i class="layui-icon"></i>电子发票</button>
         <?php if(\think\Session::get('usertype')=="0"): ?>
        <!--<button class="layui-btn " onclick="onekeyBillList2()"><i class="layui-icon"></i>一键收款2</button>-->
        <?php endif; ?>
        <span class="x-right" style="line-height:40px">账单总金额： <?php echo $billsum; ?>  元 &nbsp;&nbsp;&nbsp;&nbsp; 共有数据： <?php echo $number; ?>  条</span>
      </xblock>
      <table class="layui-table"  id="table">
        <thead>
          <tr>
            <th style="text-align: center; font-size: 16px;">
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th style="text-align: center; font-size: 16px;">小区名称</th>
            <th style="text-align: center; font-size: 16px;">完整门牌</th>
            <th style="text-align: center; font-size: 16px;">业主姓名</th>
            <th style="text-align: center; font-size: 16px;">手机</th>
            <th style="text-align: center; font-size: 16px;">费用类型</th>
            <th style="text-align: center; font-size: 16px;">账期</th>
            <th style="text-align: center; font-size: 16px;">应收金额</th>
           
           
           
            <th style="text-align: center; font-size: 16px;">付款类型</th>
            <th style="text-align: center; font-size: 16px;">付款时间</th>
            <th style="text-align: center; font-size: 16px;">账单状态</th>
            <th style="text-align: center; font-size: 16px;width: 5%">发票状态</th>
           
            <th style="text-align: center; font-size: 16px;width: 20%">操作</th>
            </tr>
        </thead>
        <tbody>
          <?php foreach($list as $val): ?>
          <tr>
            <td style="text-align: center;">
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='<?php echo $val['id']; ?>'><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td style="text-align: center;"><?php echo $val['community_id']; ?></td>
            <td style="text-align: center;"><?php echo $val['room_address']; ?></td>
            <td style="text-align: center;"><?php echo $val['owner_name']; ?></td>
            <td style="text-align: center;"><?php echo $val['owner_phone']; ?></td>
            <td style="text-align: center;"><?php echo $val['cost_type']; ?></td>
            <td style="text-align: center;"><?php echo $val['acct_period']; ?></td>
            <td style="text-align: center;"><?php echo $val['bill_entry_amount']; ?></td>
            <!--<td style="text-align: center;"><?php echo $val['discount_money']; ?></td>-->
            
            <!--<td style="text-align: center;"><?php echo $val['deadline']; ?></td>-->
            <td style="text-align: center;"><?php echo $val['pay_type']; ?></td>
            <td style="text-align: center;">
              <?php if($val['status'] == 'TRADE_SUCCESS'): ?>
              <?php echo $val['gmt_payment']; endif; ?>
            </td>
            <td style="text-align: center;">
              <?php if($val['status'] == 'TRADE_SUCCESS'): ?>
                已付款
              <?php elseif($val['status'] == 'UNDER_PAYMENT'): ?>
                待支付
              <?php elseif($val['status'] == 'WAIT_PAYMENT'): ?>
                待付款
              <?php elseif($val['status'] == 'OUT_OF_DATE'): ?>
                已逾期
              <?php endif; ?>
            </td>
           
            <!--<td style="text-align: center;"><?php echo $val['ticket']; ?></td>
            <td style="text-align: center;"><?php echo $val['invoice_serial_num']; ?></td>-->
            <td style="text-align: center;">
              <?php if($val['invoice_type'] == '1'): ?>
                已开发票
              <?php elseif($val['invoice_type'] == '2'): ?>
                已退票
              <?php else: endif; ?>
            </td>
            <!--<td style="text-align: center;"><?php echo $val['remarks']; ?></td>-->
            <td class="td-manage" style="text-align: center;">
             
              <?php if($val['invoice_type'] == 1 ||  $val['invoice_type'] == 2): ?>
              <button class="layui-btn" onclick="x_admin_show('查看发票','<?php echo url('admin/invoice/CheckEInvoice'); ?>?id=<?php echo $val['id']; ?>',900,700)">查看</button>
              <!--<a title="查看发票"  onclick="x_admin_show('查看发票','<?php echo url('admin/invoice/CheckEInvoice'); ?>?id=<?php echo $val['id']; ?>',900,700)" href="javascript:;">
                <i class="layui-icon">&#xe64a;</i>
              </a>-->
              <?php endif; if($val['invoice_type'] == 1): ?>
              <!--<a title="冲红"  onclick="x_admin_show('冲红','<?php echo url('admin/Bill/Cancellation'); ?>?id=<?php echo $val['id']; ?>',700,600)" href="javascript:;">
                <i class="layui-icon">&#xe6b2;</i>
              </a>-->
             <!--<button class="layui-btn layui-btn-danger" onclick="cancellation('<?php echo $val['id']; ?>', '<?php echo $val['id']; ?>')" id="red<?php echo $val['id']; ?>">冲红</button>-->
              <!--<a title="冲红" onclick="cancellation('<?php echo $val['id']; ?>', '<?php echo $val['id']; ?>')" href="javascript:;" id="red<?php echo $val['id']; ?>">
                    <i class="layui-icon">&#xe6b2;</i>
                  </a>-->
              <?php endif; if($val['invoiceCode']): ?>
              <button class="layui-btn  layui-btn-normal" onclick="x_admin_show('再次提交','<?php echo url('invoice/delivery'); ?>?id=<?php echo $val['id']; ?>',600,400)">再次提交</button>
              
              
              <?php endif; ?>
                
                
                
              
				
            </td>
          </tr>
          <?php endforeach; ?>
        </tbody>
      </table>
      <div class="page">
        <div>
          <?php echo $billlist->render(); ?>
        </div>
      </div>

    </div>
    <script>
      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
          ,format: 'yyyy-MM-dd HH:mm:ss'
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
          ,format: 'yyyy-MM-dd HH:mm:ss'
        });
      });
      function cancellation(id, doc){
        if(confirm('是否确定冲红?')) 
        { 

          var url = "<?php echo url('invoice/Cancellation'); ?>?id=" + id
          // console.log(url)
          window.location.href=url
          $('#red' + doc).attr('href', url)
        } 
          return false; 
      }
        //删除
      
      function billDelId(id, doc){
        if(confirm('删除后无法恢复，确定要删除吗?')) 
        { 
          var url = "<?php echo url('billDelId'); ?>?id=" + id
          // console.log(url)
          $('#' + doc).attr('href', url)
        } 
          return false; 
      } 

      //批量删除
      function delAll () {
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        //window.location.href='<?php echo url("billDel"); ?>?id='+str;
        layer.confirm('你确定要删除这'+ count + '项吗', function(){
          $.post('<?php echo url("billDel"); ?>', { id: str}, function(r){
            if (r.info) {
              layer.msg(r.info)
              location.reload()
            }else{
              layer.msg(r.error)
              location.reload()
            }
          })
        })
      }

      //批量打印
      function printing () {
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        layer.confirm('你确定要打印这'+ count + '项吗', function(){
          $.post('<?php echo url("admin/Bill/Printing"); ?>', { id: str}, function(r){
            if (r.info) {
              layer.msg(r.info)
              location.reload()
            }else{
              layer.msg(r.error)
              location.reload()
            }
          })
        })
      }
      
      //批量同步
      function billUpload(){
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        
        var count = ids.length
        
        if(count=="0"){
            layer.msg("请选择要同步的账单");
            return ;
        }
        //window.location.href="<?php echo url("billUpload"); ?>?id="+str;
        layer.confirm('你确定要同步这'+ count + '项吗', function(){
          $.post('<?php echo url("billUpload"); ?>', { id: str}, function(r){
            if (r.info) {
              layer.msg(r.info)
              setTimeout(function (){
                	window.location.reload();
                }, 1000)
            }else{
              layer.msg(r.error)
              setTimeout(function (){
                	window.location.reload();
                }, 1000)
            }
          })
        })
      }

      //批量导出
      function billExportExcel(exportid){
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
        var url = "<?php echo url('admin/bill/billExportExcel'); ?>?id=" + str +'&export=' + exportid
        console.log(url);
        layer.open({
          type: 2,
          title: '批量导出账单',
          shadeClose: true,
          shade: 0.8,
          area: ['80%', '95%'],
          content: url //iframe的url
        }); 
      }

      //一键收款
      function onekeyBillList() {
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
       
        var url = "<?php echo url('onekeyBillList'); ?>?id=" + str
        layer.open({
          type: 2,
          title: '一键收款',
          shadeClose: true,
          shade: 0.8,
          area: ['60%', '70%'],
          content: url //iframe的url
        }); 
      }

      //一键收款
      function onekeyBillList2() {
        var datas = $('#table tbody td .layui-form-checked')
        var ids = []
        datas.each(function(index, element){
          var id = $(this).data('id')
          ids.push(id)
        })

        var str = ids.join(',');
        var count = ids.length
       
        var url = "<?php echo url('onekeyBillList2'); ?>?id=" + str
        layer.open({
          type: 2,
          title: '一键收款',
          shadeClose: true,
          shade: 0.8,
          area: ['60%', '70%'],
          content: url //iframe的url
        }); 
      }


      //批量开票
      function invoice(){
        if(confirm('是否确定开票?')){
          var datas = $('#table tbody td .layui-form-checked')
          var ids = []
          datas.each(function(index, element){
            var id = $(this).data('id')
            ids.push(id)
          })

          var str = ids.join(',');
          var count = ids.length
          var url = "<?php echo url('admin/invoice/invoice'); ?>?id=" + str
          layer.open({
            type: 2,
            title: '批量开票',
            shadeClose: true,
            shade: 0.8,
            area: ['80%', '95%'],
            content: url //iframe的url
          }); 
        }
        
        
      }
    </script>
    <!-- 多条件查询 -->
    <script>

      layui.use(['form'], function() {
          var form = layui.form
          $("#foundkeycommunity").blur(function(){
            var _this = $(this);
            var foundkeycommunity=_this.val();
            //layer.alert(foundkeycommunity);
            var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
              $.post(url, {community_name: foundkeycommunity, type: 5}, function(data) {
                  //console.log(data);
                  $('#community_id').html("")
                  var option = "<option value=''>所属小区</option>"
                  $('#community_id').append(option)
                  for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i]["community_id"] + "'>" + data[i]["community_name"] + "</option>"
                  $('#community_id').append(option)
                  }
                  
                  form.render('select')
              })
          })
          form.on('select(community_id)', function(f){
              var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
              $.post(url, {community_id: f.value, type: 1}, function(data) {
                console.log(data);
                  $('#group').html("")
                  var option = "<option value=''>所有组团</option>"
                  $('#group').append(option)
                  for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#group').append(option)
                  }
                  
                  form.render('select')
              })
              
              $('#community_id').data('community_id', f.value)
          })

          form.on('select(group)', function(f){
              var data_community = $('#community_id').data('community_id')
              var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
              var community_id = typeof data_community === 'undefined' ? get_community : data_community
              var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
              $.post(url, {community_id: community_id, group: f.value, type: 2}, function(data) {
                  $('#building').html("")
                  var option = "<option value=''>所有楼栋</option>"
                  $('#building').append(option)
                  for (var i = 0; i < data.length; i++) {
                      option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                      $('#building').append(option)
                  }
                  $('#group').data('group', f.value)
                  form.render('select')
              })
          })
  
          form.on('select(building)', function(f){
              var data_community = $('#community_id').data('community_id')
              var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
              var community_id = typeof data_community === 'undefined' ? get_community : data_community

              var data_group = $('#group').data('group')
              var get_group = "<?php if (isset($group)) { echo $group;}?>"
              var group = typeof data_group === 'undefined' ? get_group : data_group

              var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
              $.post(url, {building: f.value, community_id: community_id, group: group, type: 3}, function(data) {
              $('#unit').html("")
              var option = "<option value=''>所有单元</option>"
              $('#unit').append(option)
              for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#unit').append(option)
              }
              $('#building').data('building', f.value)
              form.render('select')
              })
          })
  
          form.on('select(unit)', function(f){
              var data_community = $('#community_id').data('community_id')
              var get_community = "<?php if (isset($community_id)) { echo $community_id;}?>"
              var community_id = typeof data_community === 'undefined' ? get_community : data_community

              var data_group = $('#group').data('group')
              var get_group = "<?php if (isset($group)) { echo $group;}?>"
              var group = typeof data_group === 'undefined' ? get_group : data_group

              var data_building = $('#building').data('building')
              var get_building = "<?php if (isset($building)) { echo $building;}?>"
              var building = typeof data_building === 'undefined' ? get_building : data_building
      
              var url = "<?php echo url('admin/Roominfo/fetchdata'); ?>"
              $.post(url, {unit: f.value, community_id: community_id, group: group, building: building, type: 4}, function(data) {
              $('#room').html("")
              var option = "<option value=''>所有房间</option>"
              $('#room').append(option)
              for (var i = 0; i < data.length; i++) {
                  option = "<option value='" + data[i] + "'>" + data[i] + "</option>"
                  $('#room').append(option)
              }
              $('#unit').data('unit', f.value)
              form.render('select')
              })
          })
  
      })
  </script>
    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();</script>
  </body>

</html>